import Vue from 'vue'
import App from './App.vue'
import router from './router'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

import './styles/base.less'

Vue.use(ElementUI)

import moment from 'moment'
Vue.filter('date', res => {
  return moment(res).format('YYYY-MM-DD hh:mm')
})

// ---------------------富文本编辑器的配置-----------------------
import VueQuillEditor from 'vue-quill-editor'

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
Vue.use(VueQuillEditor)

// ********   axios  ********************* */
import axios from 'axios'

// axios 请求拦截器 => 拦截请求 => 添加token
axios.interceptors.request.use(config => {
  let token = localStorage.getItem('token')
  if (token) {
    config.headers.Authorization = token
  }

  return config
})

// axios 响应拦截器 => 拦截响应 => 验证token是否失效

axios.defaults.baseURL = 'http://127.0.0.1:3000'
Vue.prototype.$axios = axios

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App),
}).$mount('#app')
